package com.bytedance.improvingroad

import com.bytedance.improvingroad.activity.BaseBindingActivity
import com.bytedance.improvingroad.databinding.ActivityBottomAppBarBinding
import com.bytedance.improvingroad.utils.Utils
import com.google.android.material.shape.MaterialShapeDrawable

class BottomAppBarActivity : BaseBindingActivity<ActivityBottomAppBarBinding>() {
    override fun initData() {
        val topEdge = BottomAppBarCutCornersTopEdge(
            binding.bottomAppBar.fabCradleMargin,
            binding.bottomAppBar.fabCradleRoundedCornerRadius,
            binding.bottomAppBar.cradleVerticalOffset
        )
        val background = binding.bottomAppBar.background as MaterialShapeDrawable
        background.shapeAppearanceModel = background.shapeAppearanceModel.toBuilder().setTopEdge(topEdge).build()
    }

    override fun initListener() {
        binding.bottomAppBar.setNavigationOnClickListener {
            Utils.showToast("导航键被点击了")
        }

        binding.bottomAppBar.setOnMenuItemClickListener { menuItem ->
            when (menuItem.itemId) {
                R.id.search -> {
                    Utils.showToast("search菜单被点击了")
                    true
                }
                R.id.more -> {
                    Utils.showToast("more菜单被点击了")
                    true
                }
                else -> false
            }
        }
    }
}